import axios from "axios";
import nprogress from "nprogress";
import "nprogress/nprogress.css";

let mockrequest = axios.create({
  baseURL: "/mock",
  timeout: 5000,
});

mockrequest.interceptors.request.use((config) => {
  nprogress.start();
  return config;
});

mockrequest.interceptors.response.use(
  (res) => {
    nprogress.done();
    return res.data;
  },
  (err) => {
    alert(err.code);
  }
);

export default mockrequest;
